package cn.yanhu.kuwanapp.http


import cn.yanhu.kuwanapp.bean.other.EditUserInfoBean
import cn.yanhu.kuwanapp.bean.other.VersionBean
import cn.yanhu.kuwanapp.bean.request.ReqPhoneLoginBean
import cn.yanhu.kuwanapp.bean.response.*
import cn.yanhu.kuwanapp.http.status.BaseBean
import retrofit2.http.*

interface ApiService {

    /**
     * 埋点
     */
    @FormUrlEncoded
    @POST("app/api/v1/newEventTrace")
    suspend fun eventTrace(@FieldMap fields:Map<String,String>): BaseBean<Any>

    /**
     * 判断更新
     */
    @GET("app/v1/appversion/check")
    suspend fun checkUpdate(): BaseBean<VersionBean>


    /**
     * 发送短信
     * @param phone String
     * @return BaseBean<Any>
     */
    @FormUrlEncoded
    @POST("app/user/v1/k/sendVerifyCode")
    suspend fun sendCode(@Field("phone")  phone:String): BaseBean<Any>

    /**
     * 微信登录
     *
     * @param wxCode 微信code
     * @param type 类型 1:登录注册 2:授权(提现页面绑定微信信息时调用)
     * @return
     */
    @FormUrlEncoded
    @POST("app/user/v1/k/wxlogin")
    suspend fun wxLogin(@Field("wxCode")  wxCode:String,@Field("type")  type:String): BaseBean<RespWxLoginBean>

    /**
     * 微信授权
     * @param wxCode String
     * @param type String
     * @return BaseBean<RespLoginBean>
     */
    @FormUrlEncoded
    @POST("app/user/v1/k/wxlogin")
    suspend fun wxAuth(@Field("wxCode")  wxCode:String,@Field("type")  type:String): BaseBean<Any>

    /**
     * 手机号验证码登录
     *
     * @param phone 手机号
     * @param code 验证码
     * @return
     */
    @POST("app/user/v1/k/login")
    suspend fun phoneLogin(@Body phone: ReqPhoneLoginBean): BaseBean<RespLoginBean>

    /**
     * 用户信息
     * @param source 0:首页 1:我的页面
     */
    @GET("app/user/v1/k/userInfo")
    suspend fun userInfo(@Query("source") source: String): BaseBean<RespUserInfoBean>

    /**
     * 首页奖励轮播
     */
    @GET("app/v1/k/index/carousel")
    suspend fun carousel(): BaseBean<RespCarouselBean>

    /**
     * 游戏列表
     *
     * @param source 0:首页 1:更多(赚钱页面)
     * @param type 类型 (0:推荐 1:快赚 2:益智 3:手游 4:最新)
     * @param pageNo 页码
     * @return
     */
    @GET("app/v1/k/index/game/list")
    suspend fun gameList(@Query("source") source: String,@Query("type") type: Int,@Query("pageNo") pageNo: Int): BaseBean<List<RespGameListBean>>

    /**
     * 游戏搜索
     *
     * @param searchtxt 搜索关键字
     */
    @GET("app/v1/k/index/game/search")
    suspend fun gameSearch(@Query("searchtxt") searchtxt: String): BaseBean<List<RespGameListBean>>

    /**
     * 主页tab标签
     */
    @GET("app/v1/tab/queryTab")
    suspend fun homeTab(): BaseBean<List<RespHomeTabBean>>

    /**
     * 视频金币领取
     * @param money String
     * @param businessType 2->看视频领金币 3->刷刷小视频 4->体验小游戏
     * @param name String
     */
    @FormUrlEncoded
    @POST("app/v1/gold/k/award")
    suspend fun videoReward(@Field("money") money:String,@Field("businessType") businessType:String,@Field("name") name:String): BaseBean<RespGoldReceiveBean>

    /**
     * 我的页面配置
     */
    @GET("app/user/v1/k/myConfig")
    suspend fun myConfig(): BaseBean<RespMyConfigBean>

    /**
     * 更新用户信息
     */
    @POST("app/user/v1/k/editUserInfo")
    suspend fun editUserInfo(@Body userInfoBean: EditUserInfoBean): BaseBean<Any>

    /**
     * 消息列表
     */
    @GET("app/message/v1/k/list")
    suspend fun msgList(@Query("endId") endId: String,@Query("pageSize") pageSize: Int): BaseBean<List<RespMsgBean>>

    /**
     * 读取消息
     */
    @FormUrlEncoded
    @POST("app/message/v1/k/read")
    suspend fun readMsg(@Field("msgId") msgId:String): BaseBean<Any>

    /**
     * 提现主页
     */
    @GET("app/v1/account/k/homePage")
    suspend fun withdrawHome(): BaseBean<RespWithdrawHomeBean>

    /**
     * 提现
     * @param money 金额
     * @param payType 提现方式
     */
    @FormUrlEncoded
    @POST("app/v1/account/k/withdraw")
    suspend fun withdraw(@Field("money") money:String,@Field("payType") payType:String): BaseBean<Any>

    /**
     * 绑定支付宝
     */
    @GET("app/v1/k/alipay/appLoginParams")
    suspend fun bindAlipay(): BaseBean<RespBindAlipayBean>

    /**
     * 绑定支付宝回调
     * @param result String
     */
    @FormUrlEncoded
    @POST("app/v1/k/alipay/appCallBack")
    suspend fun bindAlipayCallBack(@Field("result") result:String): BaseBean<Any>

    /**
     * 提现记录
     * @param type 1:全部 2:收入 3:提现
     * @param pageNo Int
     * @param pageSize Int
     */
    @GET("app/v1/account/k/detail/record")
    suspend fun withdrawRecords(@Query("type") type: Int,@Query("pageNo") pageNo: Int,@Query("pageSize") pageSize: Int): BaseBean<RespWithdrawRecordBean>

    /**
     * 我的任务
     */
    @GET("app/v1/k/index/game/joined")
    suspend fun taskList(@Query("pageNo") pageNo: Int): BaseBean<List<RespTaskListBean>>
}